/*
    The MIT License

    Copyright (c) 2010 IFMO/GameDev Studio

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
*/

#pragma once

/*-----------------------------------------------------------------------------
	UI interfaces :
-----------------------------------------------------------------------------*/

class	IUIFont;
class	IUIPage;
class	IUIControl;
typedef HardRef<IUIFont>		IPxUIFont;
typedef HardRef<IUIPage>		IPxUIPage;
typedef HardRef<IUIControl>	IPxUIControl;

struct EUIQuad {
		EPoint		p0;
		EPoint		p1;
		ETexCoord	uv0;
		ETexCoord	uv1;
		EColor		color;
	};

class IUIDrawCB {	
	public:
		virtual void	RenderQuads		( uint quad_num, const EUIQuad *quads, EString image ) = 0;	
		virtual void	GetImageSize	( EString image, uint &width, uint &height ) = 0;
	};


class IUIPage : public ICoreObject {	
	public:
		virtual void			Enter			( void ) = 0;
		virtual void			Leave			( void ) = 0;
		virtual void			AttachControl	( IPxUIControl control ) = 0;
		virtual void			DetachControl	( IPxUIControl control ) = 0;
		virtual IPxUIControl	GetControl		( uint index ) = 0;
	};


class IUIControl : public ICoreObject {
	public:
		virtual void	Render			( void ) = 0;
		virtual void	Update			( float dtime ) = 0;

		virtual void	Enter			( void ) = 0;
		virtual void	Leave			( void ) = 0;

		virtual void	Focus			( bool focused ) = 0;
		virtual void	MouseOver		( bool over ) = 0;
		virtual bool	MouseMove		( float x, float y ) = 0;
		virtual bool	MouseLButton	( bool down ) = 0;
		virtual bool	MouseRButton	( bool down ) = 0;
		virtual bool	MouseWheel		( int notches ) = 0;
		virtual bool	KeyClick		( int key, int chr ) = 0;
	};
	


class IUIFont : public ICoreObject {
	public:
		virtual void		DrawString				( float x, float y, EString text, const EColor &color ) = 0;
		virtual float		StringLength			( EString text ) = 0;
		virtual float		GetLineHeight			( void ) const = 0;
		virtual float		GetCharWidth			( char ch ) const = 0;
	};


class IUserInterface {
	public:
							~IUserInterface			( void ) {};
							
		virtual IPxUIFont	CreateFont				( const EString font ) = 0;
							
		virtual void		DrawStringMT			( float x, float y, float size, float tracking, EString image, EString text, const EColor &color ) = 0;
									
		virtual void		DrawRect				( float x, float y, float w, float h, EString image, const EColor &color ) = 0;
		virtual void		DrawBorderRect			( float x, float y, float w, float h, EString image, const EColor &color ) = 0;
		virtual void		DrawBorderRectTop		( float x, float y, float w, float h, EString image, const EColor &color ) = 0;
		virtual void		DrawBorderRectBottom	( float x, float y, float w, float h, EString image, const EColor &color ) = 0;
	};